#!/bin/ash

# Pull in custom CAs from /usr/local/share/ca-certificates/
/usr/sbin/update-ca-certificates

# Verify timezone is valid
/set_timezone
if [ $? -ne 0 ]
then
  exit 1
fi

# Start CRON
set -f
case "$SCAN_INTERVAL" in
  5m)  CRON_S="*/5 *"
  ;;
  10m) CRON_S="*/10 *"
  ;;
  15m) CRON_S="*/15 *"
  ;;
  30m) CRON_S="*/30 *"
  ;;
  1h)  CRON_S="0 *"
  ;;
  2h)  CRON_S="0 */2"
  ;;
  4h)  CRON_S="0 */4"
  ;;
  6h)  CRON_S="0 */6"
  ;;
  12h) CRON_S="0 */12"
  ;;
  *)   CRON_S="0 *"
  ;;
esac

echo "$CRON_S *  *  * /usr/bin/php /phpipam/functions/scripts/discoveryCheck.php"      >/etc/crontabs/apache
echo "$CRON_S *  *  * /usr/bin/php /phpipam/functions/scripts/pingCheck.php"          >>/etc/crontabs/apache
echo "$CRON_S *  *  * /usr/bin/php /phpipam/functions/scripts/resolveIPaddresses.php" >>/etc/crontabs/apache

/usr/sbin/crond -f -l 8 -L /dev/stdout
